Skip to content

Fix npmnpmrcproject fixture: scope legacy auth keys to the registry - #3681

Open
agrasth wants to merge 2 commits into
masterfrom
fix/npm-npmrc-fixture-email-key
Open

Fix npmnpmrcproject fixture: scope legacy auth keys to the registry#3681
agrasth wants to merge 2 commits into
masterfrom
fix/npm-npmrc-fixture-email-key

Conversation

@agrasth

@agrasth agrasth commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • npm 12 hard-rejects the bare email and _auth npmrc auth config keys with ERR_INVALID_AUTH, which was failing TestNpmNativeSyntax/npm_i_with_npmrc_project (and the equivalent legacy-syntax test) for every npm 12.x version in our pm-version-monitor compatibility tracking — the very first npm install call in the test errored out before jfrog-cli's own npm command logic ever ran.
  • This is a test-fixture staleness issue, not a jfrog-cli npm command bug: testdata/npm/npmnpmrcproject/.npmrc still used the pre-npm-12 unscoped auth key format.
  • Scope both keys to the registry host, matching the format the fixture's existing _authToken line already uses (and exactly what npm's own error message names as the fix).

Test plan

  • Verified locally: npm install --dry-run against the original fixture with npm 12.0.0 reproduces ERR_INVALID_AUTH: Invalid auth configuration found: 'email' must be renamed to '//<registry>/:email' in project config
  • Verified the fixed fixture passes config validation with npm 12.0.0 (fails only on ENOTFOUND for the fixture's placeholder NO-NO-REPO host, which is expected — the real test redirects to a live Artifactory instance)
  • go vet ./... and gofmt — no changes needed, fixture-only diff

npm 12 hard-rejects the bare (unscoped) `email` and `_auth` auth
config keys with ERR_INVALID_AUTH — a validation change from npm's
own auth-config cleanup, not a jfrog-cli npm command bug. Every
npm 12.x compatibility test failed at the very first `npm install`
call in TestNpmNativeSyntax/npm_i_with_npmrc_project because the
fixture's .npmrc still used the old unscoped format:

  _auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl
  email=ddd@dd.dd

npm's own error message names the fix: scope both keys to the
registry, matching how the existing _authToken line is already
scoped:

  //NO-NO-REPO/:_auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl
  //NO-NO-REPO/:email=ddd@dd.dd

Verified locally with the exact npm 12.0.0 that failed in CI —
`npm install --dry-run` against the fixed .npmrc no longer raises
ERR_INVALID_AUTH (it fails only on ENOTFOUND for the fixture's
fake NO-NO-REPO host, which is expected and unrelated: the real
test always redirects to a live Artifactory instance via jfrog-cli).
golangci-lint (staticcheck SA1019) started failing on this PR's CI run
because master recently bumped to Go 1.26, which deprecates
httputil.ReverseProxy.Director in favor of Rewrite (available since
Go 1.20). Unrelated to the npm fixture change in this PR, but it
blocks the CI gate regardless, so fixing it here.

Direct translation: Rewrite receives a *httputil.ProxyRequest whose
.Out field is a pre-cloned copy of the incoming request, so the
closure only needs to set the same three fields Director set
directly on the request (Host, URL.Host, URL.Scheme). Defining a
custom Rewrite func means none of the automatic default behavior
(X-Forwarded-For, etc.) kicks in, matching Director's original
no-defaults behavior exactly -- this is a mechanical migration with
no functional change.

Verified with the exact CI lint invocation (golangci-lint 2.13.1,
same flag set) against both the changed package and the full repo:
0 issues.
@agrasth
agrasth deployed to build-gate August 25, 2026 09:25 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Frogbot scanned this pull request and found the below:

View full scan results in JFrog Platform

📗 Scan Summary

  • Frogbot scanned for vulnerabilities and found 1 issues
Scan Category Status Security Issues
Software Composition Analysis ✅ Done Not Found
Contextual Analysis ✅ Done -
Static Application Security Testing (SAST) ✅ Done
1 Issues Found 1 High
Secrets ✅ Done Not Found
Infrastructure as Code (IaC) ✅ Done Not Found

pr.Out.URL.Scheme = target.Scheme
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
high
High
TLS settings are configured insecurely, exposing communications to risks
Full description

Vulnerability Details

Rule ID: go-insecure-tls

Overview

Insecure TLS Configuration is a type of vulnerability that occurs when an
application uses weak or outdated cryptographic protocols, ciphers, or
configurations for secure communication over the network.

Vulnerable example

package main

import (
    "crypto/tls"
)

func main() {}

func insecureMinMaxTlsVersion() {
    {
        config := &tls.Config{}
        config.MinVersion = 0
    }
    {
        config := &tls.Config{}
        config.MinVersion = tls.VersionSSL30
    }
    {
        config := &tls.Config{}
        config.MaxVersion = tls.VersionSSL30
    }
    {
        config := &tls.Config{}
    }
}

func insecureCipherSuites() {
    config := &tls.Config{
        CipherSuites: []uint16{
            tls.TLS_RSA_WITH_RC4_128_SHA,
        },
    }
    _ = config
}

In this example, the MinVersion field is set to tls.VersionSSL30, which
uses the outdated SSL 3.0 protocol, making the application vulnerable to
attacks such as POODLE.

Remediation

package main

import (
    "crypto/tls"
)

func main() {}

func insecureMinMaxTlsVersion() {
    {
        config := &tls.Config{}
-       config.MinVersion = 0
+       config.MinVersion = tls.VersionTLS12
    }
    {
        config := &tls.Config{}
-       config.MinVersion = tls.VersionSSL30
+       config.MinVersion = tls.VersionTLS12
    }
    {
        config := &tls.Config{}
-       config.MaxVersion = tls.VersionSSL30
    }
    {
-       config := &tls.Config{}
+       config := &tls.Config{MinVersion: tls.VersionTLS12}
    }
}

func insecureCipherSuites() {
    config := &tls.Config{
        CipherSuites: []uint16{
-           tls.TLS_RSA_WITH_RC4_128_SHA,
+           tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
        },
+       MinVersion: tls.VersionTLS12,
    }
    _ = config
}

By using safe TLS versions (e.g., tls.VersionTLS12) and secure cipher suites we can
mitigate the risk of insecure TLS configurations and improve the security of the
application.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant